/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.primecodegen.common.bean;

//<editor-fold defaultstate="collapsed" desc="Imports">
import com.primecodegen.common.DataModelAttributes.DataModelAttributesDAO;
import com.primecodegen.common.DataModelAttributes.DataModelAttributesTable;
import com.primecodegen.common.DataModelObject.DataModelObjectDAO;
import com.primecodegen.common.DataModelObject.DataModelObjectTable;
import com.primecodegen.common.DataModelProject.DataModelProjectDAO;
import com.primecodegen.common.DataModelProject.DataModelProjectTable;
import com.primecodegen.common.DmAttrProp.DmAttrPropDAO;
import com.primecodegen.common.DmAttrProp.DmAttrPropTable;
import com.primecodegen.common.DmObjProp.DmObjPropDAO;
import com.primecodegen.common.DmObjProp.DmObjPropTable;
import com.primecodegen.common.DmPrjProp.DmPrjPropDAO;
import com.primecodegen.common.DmPrjProp.DmPrjPropTable;
import com.primecodegen.common.GeneratedTargets.GeneratedTargetsDAO;
import com.primecodegen.common.GeneratedTargets.GeneratedTargetsTable;
import com.primecodegen.common.MainProject.MainProjectTable;
import com.primecodegen.common.base.BaseBean;
import com.primecodegen.util.util;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.primefaces.model.TreeNode;
//</editor-fold>

/**
 *
 * @author Mohammad
 */
@ManagedBean(name = "generateWizardBean")
@SessionScoped
public class GenerateWizardBean extends BaseBean implements Serializable{

    //<editor-fold defaultstate="collapsed" desc="Instance Variables">
    private MainProjectTable selectedMainProjectTable;
    private DataModelProjectTable selectedDataModelProjectTable;
    private DataModelObjectTable selectedDataModelObjectTable;
    private DataModelAttributesTable selectedDataModelAttributesTable;
    //
    private DataModelProjectTable insertDataModelProjectTable;
    private DataModelObjectTable insertDataModelObjectTable;
    private DataModelAttributesTable insertDataModelAttributesTable;
    //
    private DmObjPropTable updateDmObjPropTable;
    private DmPrjPropTable updateDmPrjPropTable;
    private DmAttrPropTable updateDmAttrPropTable;
    //
    private DmPrjPropTable dmPrjPropTable;
    private DmObjPropTable dmObjPropTable;
    private DmAttrPropTable dmAttrPropTable;
    //
    private ArrayList<SelectItem> dataModelProjectList;
    private ArrayList<SelectItem> dataModelObjectsList;
    private ArrayList<SelectItem> dataModelAttributesList;
    private ArrayList<SelectItem> attributesDataTypeArrayList=new ArrayList<SelectItem>();
    //
    private ArrayList<DataModelProjectTable> dataModelProjectTables ;
    private ArrayList<DataModelAttributesTable> dataModelAttributesTables ;
    private ArrayList<DataModelObjectTable> dataModelObjectTables;
    //
    private ArrayList<DmPrjPropTable> dmPrjPropTables;
    private ArrayList<DmObjPropTable> dmObjPropTables;
    private ArrayList<DmAttrPropTable> dmAttrPropTables;
    //
    private ArrayList<GeneratedTargetsTable> selectedGenObjects;
    private ArrayList<GeneratedTargetsTable> genObjectsList;
    //
    private DataModelProjectDAO dataModelProjectDAO;
    private DataModelObjectDAO dataModelObjectsDAO;
    private DataModelAttributesDAO dataModelAttributesDAO;
    private GeneratedTargetsDAO generatedTargetsDAO;
    //
    private DmPrjPropDAO dmPrjPropDAO;
    private DmObjPropDAO dmObjPropDAO;
    private DmAttrPropDAO dmAttrPropDAO;
    //
    private FacesContext context = FacesContext.getCurrentInstance();
    HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
    HttpSession httpSession = request.getSession(false);
    
    
    private TreeNode root;  

    //</editor-fold>
    //<editor-fold defaultstate="collapsed" desc="Constructors">
    public GenerateWizardBean() {
        Initialize();
    }
    //</editor-fold>
    //<editor-fold defaultstate="collapsed" desc="Business Methods">

    public void getAllDataModelProject() {
        dataModelProjectList = new ArrayList<SelectItem>();
        DataModelProjectTable groupTable = new DataModelProjectTable();
        DataModelProjectTable srchCriteria = new DataModelProjectTable();
        srchCriteria.setMainProject_ID(selectedMainProjectTable.getID());
        if (!util.isEmpty(selectedMainProjectTable.getID())) {
            srchCriteria.setFilter(true);
        }
        dataModelProjectList.add(new SelectItem("", "- Select Role -"));
        try {

            Iterator itDataModelProject = dataModelProjectDAO.getByCriterionOrderedBy(srchCriteria, null).iterator();
            while (itDataModelProject.hasNext()) {
                groupTable = (DataModelProjectTable) itDataModelProject.next();
                dataModelProjectList.add(new SelectItem(groupTable.getID(), groupTable.getCode()));
                groupTable = new DataModelProjectTable();
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void getAllDataModelObjects() {
        dataModelObjectsList = new ArrayList<SelectItem>();
        DataModelObjectTable groupTable = new DataModelObjectTable();
        DataModelObjectTable srchCriteria = new DataModelObjectTable();
        srchCriteria.setDataModelProject_ID(selectedDataModelProjectTable.getID());
        if (!util.isEmpty(selectedDataModelProjectTable.getID())) {

            srchCriteria.setFilter(true);
        }

        dataModelObjectsList.add(new SelectItem("", "- Select Role -"));
        try {

            Iterator itDataModelObject = dataModelObjectsDAO.getByCriterionOrderedBy(srchCriteria, null).iterator();
            while (itDataModelObject.hasNext()) {
                groupTable = (DataModelObjectTable) itDataModelObject.next();
                dataModelObjectsList.add(new SelectItem(groupTable.getID(), groupTable.getCode()));
                groupTable = new DataModelObjectTable();
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void getProjectProperties() {
        dmPrjPropTables = new ArrayList<DmPrjPropTable>();
        DmPrjPropTable propTable = new DmPrjPropTable();
        DmPrjPropTable srchCriteria = new DmPrjPropTable();
        srchCriteria.setDataModelProject_ID(selectedDataModelProjectTable.getID());
        if (!util.isEmpty(selectedDataModelProjectTable.getID())) {
            srchCriteria.setFilter(true);
        }

        try {

            Iterator itDataModelProject = dmPrjPropDAO.getByCriterionOrderedBy(srchCriteria, null).iterator();
            while (itDataModelProject.hasNext()) {
                propTable = (DmPrjPropTable) itDataModelProject.next();
                dmPrjPropTables.add(propTable);
                propTable = new DmPrjPropTable();
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void getObjectsProperties() {
        dmObjPropTables = new ArrayList<DmObjPropTable>();
        DmObjPropTable propTable = new DmObjPropTable();
        DmObjPropTable srchCriteria = new DmObjPropTable();
        srchCriteria.setDataModelObject_ID(selectedDataModelObjectTable.getID());
        if (!util.isEmpty(selectedDataModelObjectTable.getID())) {
            srchCriteria.setFilter(true);
        }

        try {

            Iterator itDataModelProject = dmObjPropDAO.getByCriterionOrderedBy(srchCriteria, null).iterator();
            while (itDataModelProject.hasNext()) {
                propTable = (DmObjPropTable) itDataModelProject.next();
                dmObjPropTables.add(propTable);
                propTable = new DmObjPropTable();
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateDataModelProject() {
        try {

            selectedDataModelProjectTable = (DataModelProjectTable) dataModelProjectDAO.getByID(selectedDataModelProjectTable.getID());

        } catch (Exception ex) {
            Logger.getLogger(GenerateWizardBean.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    public void refreshProjectProperties() {
        getProjectProperties();
    }

    public void refreshObjectsProperties() {
        getObjectsProperties();
    }

    public void prepareToUpdate() {
        try {
            Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
            dmPrjPropTable.setID(new Integer(params.get("dmPrjPropIDparm")));
            prepareDmPrjPropTbleToUpdate(dmPrjPropTable.getID());

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public void prepareToUpdateObj() {
        try {
            Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
            dmObjPropTable.setID(new Integer(params.get("dmObjPropIDparm")));
            prepareDmObjPropTbleToUpdate(dmObjPropTable.getID());

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public void prepareDmPrjPropTbleToUpdate(int id) {
        try {
            dmPrjPropTable = (DmPrjPropTable) dmPrjPropDAO.getByID(id);
        } catch (Exception ex) {
            Logger.getLogger(GenerateWizardBean.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void prepareDmObjPropTbleToUpdate(int id) {
        try {
            dmObjPropTable = (DmObjPropTable) dmObjPropDAO.getByID(id);
        } catch (Exception ex) {
            Logger.getLogger(GenerateWizardBean.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void updateProjectPropsDatatable() {
        Iterator it = dmPrjPropTables.iterator();
        int updateByID = -1;
        DmPrjPropTable object = new DmPrjPropTable();
        try {
            while (it.hasNext()) {
                object = (DmPrjPropTable) it.next();
                updateByID = dmPrjPropDAO.updateByID(object);
            }

        } catch (Exception ex) {
            Logger.getLogger(GenerateWizardBean.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void updateProjectProps() {
        try {
            int updateByID = -1;
            updateByID = dmPrjPropDAO.updateByID(dmPrjPropTable);
            if (updateByID != -1) {
                getContext().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Update completed", "Update completed"));
            }
        } catch (Exception ex) {
            getContext().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Exception", "exception :" + ex));
            Logger.getLogger(GenerateWizardBean.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    public void updateObjectProps() {
        try {
            int updateByID = -1;
            updateByID = dmObjPropDAO.updateByID(dmObjPropTable);
            if (updateByID != -1) {
                getContext().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Update completed", "Update completed"));
            }
        } catch (Exception ex) {
            getContext().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Exception", "exception :" + ex));
            Logger.getLogger(GenerateWizardBean.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    public void addNewDMProject() {
        try {
            insertDataModelProjectTable.setMainProject_ID(selectedMainProjectTable.getID());
            int insert = dataModelProjectDAO.insert(insertDataModelProjectTable);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public void addNewDMObject() {
        try {
            insertDataModelObjectTable.setDataModelProject_ID(selectedDataModelProjectTable.getID());
            int insert = dataModelObjectsDAO.insert(insertDataModelObjectTable);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public void updatePrjPropVal() {
        try {
            int updateByID = -1;
            updateByID = dmPrjPropDAO.updateByID(updateDmPrjPropTable);
            if (updateByID != -1) {
                getContext().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Update completed", updateDmPrjPropTable.getPrjPropCode() + " has been  updated to " + updateDmPrjPropTable.getValue()));
            }
        } catch (Exception ex) {
            getContext().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Exception", "exception :" + ex));
            Logger.getLogger(GenerateWizardBean.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    public void updateObjPropVal() {
        try {
            int updateByID = -1;
            updateByID = dmObjPropDAO.updateByID(updateDmObjPropTable);
            if (updateByID != -1) {
                getContext().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Update completed", updateDmObjPropTable.getObjPropCode() + " has been  updated to " + updateDmObjPropTable.getValue()));
            }
        } catch (Exception ex) {
            getContext().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Exception", "exception :" + ex));
            Logger.getLogger(GenerateWizardBean.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    public void updateAttrPropVal() {
        try {
            int updateByID = -1;
            updateByID = dmAttrPropDAO.updateByID(updateDmAttrPropTable);
            if (updateByID != -1) {
                getContext().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Update completed", updateDmAttrPropTable.getAttrPropCode() + " has been  updated to " + updateDmAttrPropTable.getValue()));
            }
        } catch (Exception ex) {
            getContext().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Exception", "exception :" + ex));
            Logger.getLogger(GenerateWizardBean.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    public void refreshAttributesProperties() {
        getAttributesProperties();
    }

//    public void getAttributesProperties() {
//        dmAttrPropTables = new ArrayList<DmAttrPropTable>();
//        DmAttrPropTable propTable = new DmAttrPropTable();
//        DmAttrPropTable srchCriteria = new DmAttrPropTable();
//        srchCriteria.setDataModelAttributes_ID(selectedDataModelAttributesTable.getID());
//        if (!util.isEmpty(selectedDataModelAttributesTable.getID())) {
//            srchCriteria.setFilter(true);
//        }
//
//        try {
//
//            Iterator itDataModelProject = dmAttrPropDAO.getByCriterionOrderedBy(srchCriteria, null).iterator();
//            while (itDataModelProject.hasNext()) {
//                propTable = (DmAttrPropTable) itDataModelProject.next();
//                dmAttrPropTables.add(propTable);
//                propTable = new DmAttrPropTable();
//            }
//
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
    public void getAttributesProperties() {
        dmAttrPropTables = new ArrayList<DmAttrPropTable>();
        DmAttrPropTable propTable = new DmAttrPropTable();
        DmAttrPropTable srchCriteria = new DmAttrPropTable();
        srchCriteria.setDataModelAttributes_ID(selectedDataModelAttributesTable.getID());
        if (!util.isEmpty(selectedDataModelAttributesTable.getID())) {
            srchCriteria.setFilter(true);
        }
        
//          TreeNode documents = new DefaultTreeNode(new Document("Documents", "-", "Folder"), root);  
       
        try {

            Iterator itDataModelProject = dmAttrPropDAO.getByCriterionOrderedBy(srchCriteria, null).iterator();
            while (itDataModelProject.hasNext()) {
                propTable = (DmAttrPropTable) itDataModelProject.next();
                dmAttrPropTables.add(propTable);
                propTable = new DmAttrPropTable();
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void getAllDataModelAttributes() {
        dataModelAttributesList = new ArrayList<SelectItem>();
        DataModelAttributesTable groupTable = new DataModelAttributesTable();
        DataModelAttributesTable srchCriteria = new DataModelAttributesTable();
        srchCriteria.setDataModelObject_ID(selectedDataModelObjectTable.getID());
        if (!util.isEmpty(selectedDataModelObjectTable.getID())) {
            srchCriteria.setFilter(true);
        }

        dataModelAttributesList.add(new SelectItem("", "- Select Attribute -"));
        try {

            Iterator itDataModelAttributes = dataModelAttributesDAO.getByCriterionOrderedBy(srchCriteria, null).iterator();
            while (itDataModelAttributes.hasNext()) {
                groupTable = (DataModelAttributesTable) itDataModelAttributes.next();
                dataModelAttributesList.add(new SelectItem(groupTable.getID(), groupTable.getCode() +"("+groupTable.getDataType()+")" ));
                groupTable = new DataModelAttributesTable();
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void getAllDataModelattr() {
        dataModelAttributesList = new ArrayList<SelectItem>();
        DataModelAttributesTable groupTable = new DataModelAttributesTable();
        DataModelAttributesTable srchCriteria = new DataModelAttributesTable();
        srchCriteria.setDataModelObject_ID(selectedDataModelObjectTable.getID());
        if (!util.isEmpty(selectedDataModelObjectTable.getID())) {
            srchCriteria.setFilter(true);
        }
        dataModelAttributesList.add(new SelectItem("", "- Select Attribute -"));
        try {

            Iterator itDataModelAttributes = dataModelAttributesDAO.getByCriterionOrderedBy(srchCriteria, null).iterator();
            while (itDataModelAttributes.hasNext()) {
                groupTable = (DataModelAttributesTable) itDataModelAttributes.next();
                dataModelAttributesList.add(new SelectItem(groupTable.getID(), groupTable.getCode()));
                groupTable = new DataModelAttributesTable();
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void addNewDMAttributes() {
        try {
            insertDataModelAttributesTable.setDataModelObject_ID(selectedDataModelObjectTable.getID());
            int insert = dataModelAttributesDAO.insert(insertDataModelAttributesTable);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public void fillGeneratedTargets() {
        try {
            GeneratedTargetsTable criteria = new GeneratedTargetsTable();
            criteria.setMainProject_ID(selectedMainProjectTable.getID());
            if (!util.isEmpty(selectedMainProjectTable.getID())) {
                criteria.setFilter(true);
            }
            genObjectsList = (ArrayList<GeneratedTargetsTable>) generatedTargetsDAO.getByCriterionOrderedBy(criteria, null);
        } catch (Exception ex) {
            Logger.getLogger(GenerateWizardBean.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

//</editor-fold>
    //<editor-fold defaultstate="collapsed" desc="Setters and Getters">
    public ArrayList<SelectItem> getDataModelProjectList() {
        getAllDataModelProject();
        return dataModelProjectList;
    }

    public void setDataModelProjectList(ArrayList<SelectItem> dataModelProjectList) {
        this.dataModelProjectList = dataModelProjectList;
    }

    public DataModelProjectTable getSelectedDataModelProjectTable() {
        return selectedDataModelProjectTable;
    }

    public void setSelectedDataModelProjectTable(DataModelProjectTable selectedDataModelProjectTable) {
        this.selectedDataModelProjectTable = selectedDataModelProjectTable;
    }

    public ArrayList<GeneratedTargetsTable> getSelectedGenObjects() {
        return selectedGenObjects;
    }

    public void setSelectedGenObjects(ArrayList<GeneratedTargetsTable> selectedGenObjects) {
        this.selectedGenObjects = selectedGenObjects;
    }

    public MainProjectTable getSelectedMainProjectTable() {
        return selectedMainProjectTable;
    }

    public void setSelectedMainProjectTable(MainProjectTable selectedMainProjectTable) {
        this.selectedMainProjectTable = selectedMainProjectTable;
    }

    public DataModelProjectDAO getDataModelProjectDAO() {
        return dataModelProjectDAO;
    }

    public void setDataModelProjectDAO(DataModelProjectDAO dataModelProjectDAO) {
        this.dataModelProjectDAO = dataModelProjectDAO;
    }

    public DmPrjPropDAO getDmPrjPropDAO() {
        return dmPrjPropDAO;
    }

    public void setDmPrjPropDAO(DmPrjPropDAO dmPrjPropDAO) {
        this.dmPrjPropDAO = dmPrjPropDAO;
    }

    public ArrayList<DmPrjPropTable> getDmPrjPropTables() {
        getProjectProperties();
        return dmPrjPropTables;
    }

    public void setDmPrjPropTables(ArrayList<DmPrjPropTable> dmPrjPropTables) {
        this.dmPrjPropTables = dmPrjPropTables;
    }

    public DmPrjPropTable getDmPrjPropTable() {
        return dmPrjPropTable;
    }

    public void setDmPrjPropTable(DmPrjPropTable dmPrjPropTable) {
        this.dmPrjPropTable = dmPrjPropTable;
    }

    public DataModelProjectTable getInsertDataModelProjectTable() {
        return insertDataModelProjectTable;
    }

    public void setInsertDataModelProjectTable(DataModelProjectTable insertDataModelProjectTable) {
        this.insertDataModelProjectTable = insertDataModelProjectTable;
    }

    public ArrayList<SelectItem> getDataModelObjectsList() {
        getAllDataModelObjects();
        return dataModelObjectsList;
    }

    public void setDataModelObjectsList(ArrayList<SelectItem> dataModelObjectsList) {
        this.dataModelObjectsList = dataModelObjectsList;
    }

    public ArrayList<DmObjPropTable> getDmObjPropTables() {
        return dmObjPropTables;
    }

    public void setDmObjPropTables(ArrayList<DmObjPropTable> dmObjPropTables) {
        this.dmObjPropTables = dmObjPropTables;
    }

    public DataModelObjectTable getSelectedDataModelObjectTable() {
        return selectedDataModelObjectTable;
    }

    public void setSelectedDataModelObjectTable(DataModelObjectTable selectedDataModelObjectTable) {
        this.selectedDataModelObjectTable = selectedDataModelObjectTable;
    }

    public DmObjPropTable getDmObjPropTable() {
        return dmObjPropTable;
    }

    public void setDmObjPropTable(DmObjPropTable dmObjPropTable) {
        this.dmObjPropTable = dmObjPropTable;
    }

    public DataModelObjectTable getInsertDataModelObjectTable() {
        return insertDataModelObjectTable;
    }

    public void setInsertDataModelObjectTable(DataModelObjectTable insertDataModelObjectTable) {
        this.insertDataModelObjectTable = insertDataModelObjectTable;
    }

    public DmPrjPropTable getUpdateDmPrjPropTable() {
        return updateDmPrjPropTable;
    }

    public void setUpdateDmPrjPropTable(DmPrjPropTable updateDmPrjPropTable) {
        this.updateDmPrjPropTable = updateDmPrjPropTable;
    }

    public DmObjPropTable getUpdateDmObjPropTable() {
        return updateDmObjPropTable;
    }

    public void setUpdateDmObjPropTable(DmObjPropTable updateDmObjPropTable) {
        this.updateDmObjPropTable = updateDmObjPropTable;
    }

    public ArrayList<SelectItem> getDataModelAttributesList() {
        getAllDataModelAttributes();
        return dataModelAttributesList;
    }

    public void setDataModelAttributesList(ArrayList<SelectItem> dataModelAttributesList) {
        this.dataModelAttributesList = dataModelAttributesList;
    }

    public DmAttrPropTable getDmAttrPropTable() {
        return dmAttrPropTable;
    }

    public void setDmAttrPropTable(DmAttrPropTable dmAttrPropTable) {
        this.dmAttrPropTable = dmAttrPropTable;
    }

    public ArrayList<DmAttrPropTable> getDmAttrPropTables() {
        return dmAttrPropTables;
    }

    public void setDmAttrPropTables(ArrayList<DmAttrPropTable> dmAttrPropTables) {
        this.dmAttrPropTables = dmAttrPropTables;
    }

    public DataModelAttributesTable getInsertDataModelAttributesTable() {
        return insertDataModelAttributesTable;
    }

    public void setInsertDataModelAttributesTable(DataModelAttributesTable insertDataModelAttributesTable) {
        this.insertDataModelAttributesTable = insertDataModelAttributesTable;
    }

    public DataModelAttributesTable getSelectedDataModelAttributesTable() {
        return selectedDataModelAttributesTable;
    }

    public void setSelectedDataModelAttributesTable(DataModelAttributesTable selectedDataModelAttributesTable) {
        this.selectedDataModelAttributesTable = selectedDataModelAttributesTable;
    }

    public DmAttrPropTable getUpdateDmAttrPropTable() {
        return updateDmAttrPropTable;
    }

    public void setUpdateDmAttrPropTable(DmAttrPropTable updateDmAttrPropTable) {
        this.updateDmAttrPropTable = updateDmAttrPropTable;
    }

    public ArrayList<GeneratedTargetsTable> getGenObjectsList() {
        fillGeneratedTargets();
        return genObjectsList;
    }

    public void setGenObjectsList(ArrayList<GeneratedTargetsTable> GenObjectsList) {
        this.genObjectsList = GenObjectsList;
    }

    public ArrayList<DataModelAttributesTable> getDataModelAttributesTables() {
        return dataModelAttributesTables;
    }

    public void setDataModelAttributesTables(ArrayList<DataModelAttributesTable> dataModelAttributesTables) {
        this.dataModelAttributesTables = dataModelAttributesTables;
    }

    public ArrayList<DataModelObjectTable> getDataModelObjectTables() {
        getAllDataModelObjects();
        return dataModelObjectTables;
    }

    public void setDataModelObjectTables(ArrayList<DataModelObjectTable> dataModelObjectTables) {
        this.dataModelObjectTables = dataModelObjectTables;
    }

    public ArrayList<DataModelProjectTable> getDataModelProjectTables() {
        return dataModelProjectTables;
    }

    public void setDataModelProjectTables(ArrayList<DataModelProjectTable> dataModelProjectTables) {
        this.dataModelProjectTables = dataModelProjectTables;
    }

    public ArrayList<SelectItem> getAttributesDataTypeArrayList() {
        attributesDataTypeArrayList=new ArrayList<SelectItem>();
        attributesDataTypeArrayList.add(new SelectItem("java.math.BigInteger"));
        attributesDataTypeArrayList.add(new SelectItem("Integer"));
        attributesDataTypeArrayList.add(new SelectItem("short"));
        attributesDataTypeArrayList.add(new SelectItem("String"));
        attributesDataTypeArrayList.add(new SelectItem("java.util.Date"));
        attributesDataTypeArrayList.add(new SelectItem("Other", "Other", "you must add a attribute property contains this other type along with the template"));
        return attributesDataTypeArrayList;
    }

    public void setAttributesDataTypeArrayList(ArrayList<SelectItem> attributesDataTypeArrayList) {
        this.attributesDataTypeArrayList = attributesDataTypeArrayList;
    }
    
    
    //</editor-fold>
    //<editor-fold defaultstate="collapsed" desc="Initializer">
    private void Initialize() {
        this.selectedMainProjectTable = new MainProjectTable();
        this.selectedDataModelProjectTable = new DataModelProjectTable();
        this.insertDataModelProjectTable = new DataModelProjectTable();
        this.insertDataModelObjectTable = new DataModelObjectTable();
        this.selectedDataModelObjectTable = new DataModelObjectTable();
//        this.selectedGenObjects = new ArrayList<GeneratedTargetsTable>();
        this.dmPrjPropTables = new ArrayList<DmPrjPropTable>();
        this.dmObjPropTables = new ArrayList<DmObjPropTable>();
        this.dataModelProjectDAO = new DataModelProjectDAO();
        this.dataModelObjectsDAO = new DataModelObjectDAO();
        this.dmObjPropDAO = new DmObjPropDAO();
        this.dmPrjPropDAO = new DmPrjPropDAO();
        this.dataModelProjectList = new ArrayList<SelectItem>();
        this.dataModelObjectsList = new ArrayList<SelectItem>();
        this.dmPrjPropTable = new DmPrjPropTable();
        this.dmObjPropTable = new DmObjPropTable();
        this.context = FacesContext.getCurrentInstance();
        this.updateDmPrjPropTable = new DmPrjPropTable();
        this.updateDmObjPropTable = new DmObjPropTable();
        this.dataModelAttributesList = new ArrayList<SelectItem>();
        this.dmAttrPropTable = new DmAttrPropTable();
        this.dmAttrPropTables = new ArrayList<DmAttrPropTable>();
        this.insertDataModelAttributesTable = new DataModelAttributesTable();
        this.selectedDataModelAttributesTable = new DataModelAttributesTable();
        this.updateDmAttrPropTable = new DmAttrPropTable();
        this.dataModelAttributesDAO = new DataModelAttributesDAO();
        this.dmAttrPropDAO = new DmAttrPropDAO();
//        this.genObjectsList = new ArrayList<GeneratedTargetsTable>();
        this.generatedTargetsDAO = new GeneratedTargetsDAO();
        
        this.dataModelProjectTables=new ArrayList<DataModelProjectTable>();
        this.dataModelObjectTables =new  ArrayList<DataModelObjectTable>();
        this.dataModelAttributesTables=new ArrayList<DataModelAttributesTable>();
    }
    //</editor-fold>
}
